package top.hcode.hoj.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import top.hcode.hoj.common.result.CommonResult;
import top.hcode.hoj.pojo.dto.BaseIdDTO;
import top.hcode.hoj.pojo.dto.QuerySampleDTO;
import top.hcode.hoj.pojo.entity.CollQuestionJudgeRecord;
import top.hcode.hoj.service.admin.AdminCollQuestionJudgeRecordService;

/**
 * @author orangej
 * @since 2025-02-15
 */
@Slf4j
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class AdminCollQuestionJudgeRecordController {

    private final AdminCollQuestionJudgeRecordService collQuestionJudgeRecordService;

    @GetMapping("/admin/coll-question-judge-record/list")
    public CommonResult<IPage<CollQuestionJudgeRecord>> getCollQuestionJudgeRecordList(QuerySampleDTO querySampleDTO) {
        return CommonResult.successResponse(collQuestionJudgeRecordService.getCollQuestionJudgeRecordList(querySampleDTO));
    }

    @PostMapping("/admin/coll-question-judge-record/save")
    public CommonResult<CollQuestionJudgeRecord> saveCollQuestionJudgeRecord(@RequestBody CollQuestionJudgeRecord collQuestionJudgeRecord) {
        return CommonResult.successResponse(collQuestionJudgeRecordService.saveCollQuestionJudgeRecord(collQuestionJudgeRecord));
    }

    @PostMapping("/admin/coll-question-judge-record/delete")
    public CommonResult<Void> deleteCollQuestionJudgeRecord(@RequestBody BaseIdDTO dto) {
        collQuestionJudgeRecordService.deleteCollQuestionJudgeRecord(dto.getId());
        return CommonResult.successResponse();
    }

}
